package cn.coastalinfo.project.drools.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Auther hadge
 * @Date 2024/6/5
 */
public enum OPeratorType {
    gt(">","大于"),
    egt(">=","大于等于"),
    lt("<","小于"),
    elt("<=","小于等于"),
    eq("==","等于"),
    neq("!=","不等于"),
    contains("contains","包含"),
    notcontains("not contains","不包含"),
    memberof("member of","包含于"),
    notmemberof("not member of","不包含于");

    @EnumValue
    private final String code;
    @JsonValue
    private final String name;

    OPeratorType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static OPeratorType of(String code) {
        for (OPeratorType VariableType : OPeratorType.values()) {
            if (VariableType.getCode().equals(code)) {
                return VariableType;
            }
        }
        return null;
    }

    public static String getDescriptionName(String code) {
        for (OPeratorType dr : OPeratorType.values()) {
            if (code.equals(dr.getCode())) {
                return dr.getName();
            }
        }
        return "";
    }
}
